#include "ResourceManager.h"
#include "..\Debug\DebugLog.h"

ResourceManager::ResourceManager(void) : m_audioEngine(nullptr)
{
}


ResourceManager::~ResourceManager(void)
{
	if (m_audioEngine != nullptr)
	{
		delete m_audioEngine;
		m_audioEngine = nullptr;
	}
}

ResourceManager* ResourceManager::m_instance = nullptr;

ResourceManager& ResourceManager::getSingleton()
{
	if (m_instance == nullptr)
		m_instance = new ResourceManager;
	return *m_instance;
}

void ResourceManager::clean()
{
	if (m_instance != nullptr)
	{
		delete m_instance;
		m_instance = nullptr;
	}
}

AudioEngine* ResourceManager::getAudioEngine()
{
	return m_audioEngine;
}

void ResourceManager::createAudioEngine(AudioEngine* p_audioEngine)
{
	if (m_audioEngine == nullptr)
	{
		m_audioEngine = p_audioEngine;
	}
	else
	{
		Debug::log("WARNING: trying to create Audio Engine when one already exists.");
		delete p_audioEngine;
	}
}